//initCommonSelect();

//打印下来控件
$('#nav-menu .ans_left > li').hover(function () {
    $(this).find('.children').animate({opacity: 'show', height: 'show'}, 200);
    $(this).find('.xialaguang').addClass('navhover');
}, function () {
    $('.children').stop(true, true).hide();
    $('.xialaguang').removeClass('navhover');
});

$(function () {
    parent.toLeftMenu('1');
})

//------------------------------提交
function submitForm(flag) {
    if (flag == '0' || flag == '6' || flag == '7' || flag == '4') {
        if (flag == '0') {
            $.messager.confirm("提示", "确定新增？", function (data) {
                if (data) {
                    linkTab("entryDeclare_customs.do", "");
                }
            });
        } else if (flag == '6') {
            $.messager.confirm("提示", "确认跳到关检综合页面？", function (data) {
                if (data) {
                    var gjh = $('#GJH').val();
                    var gjglmm = $('#GJGLMM').val();
                    if (gjh != "") {
                        //window.location.href
                        // ="dataQuery_queryBygjh.do?flag=export&gjh="+gjh.trim()+"&gjglmm="+gjglmm.trim();
                        linkTab("dataQuery_queryBygjh.do?flag=import&gjh=" + gjh.trim()
                                + "&gjglmm=" + gjglmm.trim(), gjh.trim());
                    } else {
                        //window.location.href="exportDeclareAndInspect_query.do";
                        linkTab("entryDeclareAndInspect_query.do", "");

                    }
                }
            });
        } else if (flag == '7') {
            $.messager.confirm("提示", "确定跳到报检单页面？", function (data) {
                if (data) {
                    var baHgbaseinfoId = $("#baHgbaseinfoId").val();
                    if (baHgbaseinfoId != "") {
                        var gjh = $('#GJH').val();
                        var gjglmm = $('#GJGLMM').val();
                        linkTab("entryInspect_queryByGjhAndGjglmm.do?jyjy.gjh=" + gjh.trim()
                                + "&jyjy.gjglmm=" + gjglmm.trim(), gjh.trim());
                    } else {
                        linkTab("entryInspect_inspect.do", "");

                    }
                }
            });
        } else if (flag == '4') {
            if ($("#myForm").valid()) {
                hgDeclareUrl = "entryDeclare_hgDeclare.do";
                alert("敬请期待!");
                //openHgZhuJian();
                //ajaxSubmit(hgDeclareUrl,"myForm");
            }
        }
    } else {
        var islock = $("#HGISLOCK").val();
        if (flag == '1') { //暂存
            var requiredsElment = getRequiredElement();  //验证检查
            equiredForRequiredsElment(requiredsElment);
            if ($("#myForm").valid()) {
                ajaxSubmit("/order/updateDeclaration", "myForm");
            }
            addRequiredForRequiredsElment(requiredsElment);
        } else if (flag == '3') {
            selectAddSelectRequired();
            if ($("#myForm").valid()) {
                ajaxSubmit("/order/save", "myForm", "callbackeee");
            }
        }

    }
}

function callbackeee(id) {
    //location.href = "/business/declaration-confirmPay?declaration_id=" + id;
    location.href = "/order/payPage?id=" + id;
}

function ajaxSubmit(url, formId, callback) {
    //ajaxSubmitBase(url, formId, "", "entryHgAjaxCallBack");
    ajaxSubmitBase(url, formId, "", callback);
}

//------------------页面加载时执行
$(function () {

    //判断运费、保费、杂费是否为率。是则币制改为不可选，否则可选。
    if ("" == "1") {
        $("#HGSB-YFBZ").attr("readonly", "readonly");
    }
    if ("" == "1") {
        $("#HGSB-BFBZ").attr("readonly", "readonly");
    }
    if ("" == "1") {
        $("#HGSB-ZFBZ").attr("readonly", "readonly");
    }

    //商品、集装箱、随附单证初始列。
    attaSerIdIndex = '0';
    boxSerIdIndex = '0';
    hggoodsSerIdIndex = '1';
    setGoodsSpxhId(hggoodsSerIdIndex);
});

checkAuthority();
